package com.example.leetcode.trainingcamp.week1.practice2;

public class Fanzhuan {


    /**
     *    1   2   3   4                               16    12    8    4
     *    5   6   7   8                               15    11    7    3
     *    9   10  11  12         --------------->     14    10    6    2
     *    13  14  15  16                              13    9     5    1
     *
     *
     * @param nums
     */



    public void reverse(int[][] nums){
        int len = nums.length;
        for (int i = 0;i<len;i++){
            for (int j = 0;j<len-i;j++){
                int t = nums[i][j];
                nums[i][j] = nums[len-1-j][len-1-i];
                nums[len-1-j][len-1-i] = t;
            }
        }
    }
}


class TestFanZhuan{
  public static void main(String[] args) {
    int[][]nums = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
    Fanzhuan f = new Fanzhuan();
    f.reverse(nums);
    int len = nums.length;
    for (int i = 0;i<len;i++){
        for (int j = 0;j<len;j++){
            System.out.print(nums[i][j]+",");
          }
      }
  }
}